package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86185
 * Date: 2023-03-19
 * Time: 10:18
 */
class Animal{//父类/基类/超类
    public String name;
    public int age;
    public Animal(String name,int age) {
        this.name = name;
        this.age = age;
    }
    public void eat () {
        System.out.println(this.name+"eating");
    }
}
//子类在完成构造之前，先帮助父类构造好
class Dog extends Animal{//子类/派生类
    String ar;
    public Dog() {

        super("haha",10);//帮助子类调用父类的构造方法，来初始化父类成员变量
    }
    public void bark() {
        System.out.println(this.name+"wolf~");
    }
}
class Cat extends Animal{//子类/派生类
    public Cat() {
        super("haha",10);//帮助子类调用父类的构造方法，来初始化父类成员变量
    }
    public void mao() {
        System.out.println(this.name+"miao~");
    }
}
public class Testdemo {
    public static void main1(String[] args) {
        Dog dog = new Dog();
        dog.age = 10;
        dog.name = "xiaohuang";
        dog.eat();
        dog.bark();
        System.out.println("========");
        Cat cat = new Cat();
        cat.age = 10;
        cat.name = "panghu";
        cat.eat();
        cat.mao();
    }

    public static void main(String[] args) {
        final int a;//只能赋值一次，不能再被改变，类似于const
        //也可以修饰类，使类不能被继承。
        a = 10;
        System.out.println(a);
    }
}
